package com.zl.learning.lambada;

import org.junit.Test;

import java.util.function.Function;
import java.util.stream.IntStream;

public class Test3 {

    @Test
    public void test1() {
        Function<Integer, Integer> f1 = r -> {
            System.out.println("f1");
            return r + r;
        };
        Function<Integer, Integer> f2 = f1.compose(r -> {
            System.out.println("f2");
            return r;
        });
        int b = f1.andThen(f2).apply(5);
        System.out.println(b);
//        int a = f2.apply(2);
//        System.out.println(a);
    }

    @Test
    public void test2() {
        Function<Integer, Integer> f1 = r -> {
            System.out.println("f1");
            return r + r;
        };
        Function<Integer, Integer> f2 = f1.andThen(r -> {
            System.out.println("f2");
            return r;
        });
        int a = f2.apply(2);
        System.out.println(a);
    }

    @Test
    public void test3() {
        Runnable r1 = () -> System.out.println("r1");
        Runnable r2 = new Runnable() {
            @Override
            public void run() {
                System.out.println("2");
            }
        };
    }

    @Test
    public void test4() {
        IntStream.rangeClosed(1,10).forEach(System.out::println);
        System.out.println("---------");
        IntStream.rangeClosed(1,10).parallel().forEach(System.out::println);
    }
}
